if __name__ == '__main__':
    result = [0 for _ in range(102)]
    result[1],result[2],result[3] = 1,2,4
    for i in range(4,102):
        result[i] = result[i-1] + result[i-2] + result[i-3]
    out = []
    while True:
        n = int(input())
        if n == 0:
            break
        out.append(result[n])
    for i in out:
        print(i)